package com.zlx.mall.biz.attribution.logback;

import ch.qos.logback.core.joran.spi.NoAutoStart;
import ch.qos.logback.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy;

/**
 * @author qingke
 * <a href="https://stackoverflow.com/questions/50927845/how-to-enable-logback-to-rotate-the-log-files-every-x-minutes-5-minutes-30-minut">stackoverflow Link</a>
 **/
@NoAutoStart
public class MultipleTimeBasedFileNamingAndTriggeringPolicy<E> extends DefaultTimeBasedFileNamingAndTriggeringPolicy<E> {

    // This is used to specify the time interval
    private Integer multiple = 1;

    @Override
    protected void computeNextCheck() {
        nextCheck = rc.getEndOfNextNthPeriod(dateInCurrentPeriod, multiple).getTime();
    }

    public Integer getMultiple() {
        return multiple;
    }

    public void setMultiple(Integer multiple) {
        if (multiple > 1) {
            this.multiple = multiple;
        }
    }
}
